﻿@{
	ViewBag.Title = "Tools";
	Layout = "~/Views/Shared/_Layout.cshtml";
}

<script type="text/javascript">

	$(function () {
		$("button[type='submit']").click(function (e) {
			e.preventDefault();

			if ($(this).closest("form").valid())
				doCalc();
		});
	});

	function doCalc() {
		zeroBlanks(document.mainform);
		var p = numval(document.mainform.p.value);
		var c = numval(document.mainform.c.value);
		var r = numval(document.mainform.r.value) / 100;
		var y = numval(document.mainform.y.value);
		var n = numval(document.mainform.n.value);

		if (document.mainform.addTiming[0].checked)
			document.mainform.fv.value = formatNumber(basicInvestment(p, r / n, y * n, c / n), 2);
		else
			document.mainform.fv.value = formatNumber(bI2(p, r / n, y * n, c / n), 2);
	}

	function bI2(p, r, y, c) {
		if (c == null) c = 0;
		if (y == 0) return p;
		return futureValue(p, r, y) + c * geomSeries(1 + r, 0, y - 1);
	}

</script>


<div class="row">
	<div class="col-sm-12 col-md-12 col-lg-12">

		<!--left content block-->
		<div class="left_col_block">
			<div class="content_block_title">
				<h5>@ViewBag.Title</h5>
				<div class="title_bottom_arrow">
					<img src="@Url.Content("~/Content/images/down_arrow.png")" alt="" /></div>
			</div>

			<!--biography 01-->
			<div class="biography_container">
				<h4 class="biography_title">Compound Interest Calculator
				</h4>

				<div class="calculator_block">
					<form method="POST" action="JavaScript:doCalc()" name="mainform">
						@Html.ValidationSummary()
					<div class="table-responsive">
						<table width="70%" border="0" cellspacing="0" cellpadding="0" class="newsletter_seach_form">
							<thead>
								<tr>
									<th colspan="4" class="calculator_title">Inputs</th>
								</tr>
							</thead>

							<tbody>
								<tr>
									<td width="25%">Current Principal:</td>
									<td width="5%" class="dollar_sign">$</td>
									<td width="35%">@Html.TextBox("p", null, new { @class = "form-control" })</td>									
									<td width="35%">&nbsp;</td>
								</tr>

								<tr>
									<td>Annual Addition:</td>
									<td width="5%" class="dollar_sign">$</td>
									<td>@Html.TextBox("c", null, new { @class = "form-control" })</td>
									<td>&nbsp;</td>
								</tr>

								<tr>
									<td colspan="2">Years to grow:</td>
									<td>@Html.TextBox("y", null, new { @class = "form-control" })</td>
									<td>&nbsp;</td>
								</tr>

								<tr>
									<td colspan="2">Interest Rate:</td>
									<td>@Html.TextBox("r", null, new { @class = "form-control" })</td>
									<td>%</td>
								</tr>

								<tr>
									<td colspan="2">Compound Interest:</td>
									<td>@Html.TextBox("n",null, new { @class = "form-control" })</td>
									<td>time(s) annually</td>
								</tr>

								<tr>
									<td colspan="2">Make additions at:</td>
									<td colspan="2">
										<table width="100%" border="0" cellspacing="0" cellpadding="0" class="newsletter_seach_form">
											<tr>
												<td width="30%">
													<div class="radio">
														<label>@Html.RadioButton("addTiming", "start", true)
															Start</label></div>
												</td>
												<td width="70%">
													<div class="radio">
														<label>@Html.RadioButton("addTiming", "end")
															End of each compounding period</label></div>
												</td>
											</tr>
										</table>
									</td>
								</tr>

								<tr>
									<td colspan="4" align="center">
										<div class="calculate_btn">
											<div class="form-group">
												<button type="submit" class="btn btn-primary">Calculate</button>
											</div>
										</div>
									</td>
								</tr>

								<tr>
									<td colspan="4" class="calculator_title">Results:</td>
								</tr>

								<tr>
									<td>Future Value:</td>
									<td class="dollar_sign">$</td>
									<td colspan="2">
										@Html.TextBox("fv", null, new { @class = "form-control" })
									</td>
								</tr>
							</tbody>
						</table>
					</div>
						</form>
				</div>

				<div class="calculate_compare">
					<h4 class="biography_title">Calculate And Compare Option Trade Returns
					</h4>

					<a href="Option_Calculator__2_.xlsx">
						<img src="@Url.Content("~/Content/images/excel.png")" alt="Download Calculator" title="Download Calculator" />
						Download Calculator</a>
				</div>


			</div>
			<!--end biography 01-->
		</div>
		<!--end left content block-->

	</div>

</div>

